package com.hk.service.order.impl;

import com.hk.commons.LongId;
import com.hk.commons.entity.order.OrderInfoHistory;
import com.hk.dao.base.impl.BaseServiceImpl;
import com.hk.service.order.IOrderInfoHistory;
import org.springframework.stereotype.Service;

/**
 * Created by Sheldon Chen on 2016/11/16.
 */
@Service
public class OrderInfoHistoryImpl extends BaseServiceImpl<OrderInfoHistory> implements IOrderInfoHistory {

    @Override
    public synchronized Long add(OrderInfoHistory orderInfoHistory) {
        Long id = null;
        if (orderInfoHistory.getId() == null) {
            id = LongId.get();
            orderInfoHistory.setId(id);

            // 设置订单ID
            orderInfoHistory.setOrderId(id.toString());
        } else {
            id = orderInfoHistory.getId();
        }
        super.save(orderInfoHistory);
        return id;
    }
}
